HAL SPI types migration

This section provides information about the HAL SPI types migration .

HAL SPI enumeration migration

HAL SPI state type definition

HAL1

HAL2

typedef enum
{
 HAL_SPI_STATE_RESET
 HAL_SPI_STATE_READY
 HAL_SPI_STATE_BUSY_TX
 HAL_SPI_STATE_BUSY_RX
 HAL_SPI_STATE_BUSY_TX_RX
 HAL_SPI_STATE_ERROR
 HAL_SPI_STATE_ABORT

 HAL_SPI_STATE_BUSY
} HAL_SPI_StateTypeDef;
typedef enum
{
 HAL_SPI_STATE_RESET
 HAL_SPI_STATE_IDLE
 HAL_SPI_STATE_TX_ACTIVE
 HAL_SPI_STATE_RX_ACTIVE
 HAL_SPI_STATE_TX_RX_ACTIVE
 HAL_SPI_STATE_FAULT
 HAL_SPI_STATE_ABORT
 HAL_SPI_STATE_INIT
 /* */
} hal_spi_state_t;

Related concept: Replaced TypeDef suffix with _t in type names

HAL SPI callback ID type definition

HAL1

HAL2

typedef enum
{
 HAL_SPI_TX_COMPLETE_CB_ID
 HAL_SPI_RX_COMPLETE_CB_ID
 HAL_SPI_TX_RX_COMPLETE_CB_ID
 HAL_SPI_TX_HALF_COMPLETE_CB_ID
 HAL_SPI_RX_HALF_COMPLETE_CB_ID
 HAL_SPI_TX_RX_HALF_COMPLETE_CB_ID
 HAL_SPI_ERROR_CB_ID
 HAL_SPI_ABORT_CB_ID
 HAL_SPI_SUSPEND_CB_ID
 HAL_SPI_MSPINIT_CB_ID
 HAL_SPI_MSPDEINIT_CB_ID
} HAL_SPI_CallbackIDTypeDef;
  • Removed from HAL2 : the callback registration is managed by dedicated functions for each SPI event. For more details, see : Callbacks register functions

  • HAL_SPI_MSPINIT_CB_ID and HAL_SPI_MSPDEINIT_CB_ID are removed because the functions HAL_SPI_MspInit() and HAL_SPI_MspDeInit() are removed.

Related concepts:


HAL SPI structure migration

HAL SPI configuration type definition

HAL1

HAL2

typedef struct
{
 uint32_t Mode;
 uint32_t Direction;
 uint32_t DataSize;
 uint32_t CLKPolarity;
 uint32_t CLKPhase;
 uint32_t BaudRatePrescaler;
 uint32_t FirstBit;
 uint32_t NSS;





 uint32_t CRCPolynomial;
 uint32_t CRCLength;
 uint32_t TxCRCInitializationPattern;
 uint32_t RxCRCInitializationPattern;




 uint32_t NSSPMode;
 uint32_t NSSPolarity;



 uint32_t TIMode;


 uint32_t CRCCalculation;


 uint32_t FifoThreshold;

 uint32_t MasterSSIdleness;

 uint32_t MasterInterDataIdleness;

 uint32_t MasterReceiverAutoSusp;


 uint32_t MasterKeepIOState;


 uint32_t IOSwap;


 uint32_t ReadyMasterManagement;


 uint32_t ReadyPolarity;
} SPI_InitTypeDef;
typedef struct
{
 hal_spi_mode_t                 mode;
 hal_spi_direction_t            direction;
 hal_spi_data_width_t           data_width;
 hal_spi_clock_polarity_t       clock_polarity;
 hal_spi_clock_phase_t          clock_phase;
 hal_spi_baudrate_prescaler_t   baudrate_prescaler;
 hal_spi_first_bit_t            first_bit;
 hal_spi_nss_pin_management_t   nss_pin_management;
} hal_spi_config_t;

typedef struct
{
  uint32_t                      crc_polynomial;
  hal_spi_crc_length_t          crc_length;
  hal_spi_crc_tx_init_pattern_t crc_tx_init_pattern;
  hal_spi_crc_rx_init_pattern_t crc_rx_init_pattern;
} hal_spi_crc_config_t;


typedef struct
{
  hal_spi_nss_pulse_t           nss_pulse;
  hal_spi_nss_polarity_t        nss_polarity;
  hal_spi_nss_mssi_delay_t      nss_mssi_delay;
} hal_spi_nss_config_t;

HAL_SPI_EnableTIMode(hal_spi_handle_t *hspi);
HAL_SPI_DisableTIMode(hal_spi_handle_t *hspi);

HAL_SPI_EnableCRC(hal_spi_handle_t *hspi);
HAL_SPI_DisableCRC(hal_spi_handle_t *hspi);

HAL_SPI_SetFifoThreshold(const hal_spi_handle_t *hspi, const hal_spi_fifo_threshold_t fifo_threshold);

HAL_SPI_SetConfigNSS(hal_spi_handle_t *hspi, const hal_spi_nss_config_t *p_config);

HAL_SPI_MASTER_SetInterDataIdlenessDelay(hal_spi_handle_t *hspi, const hal_spi_master_inter_data_idleness_delay_t nb_cycles);

HAL_SPI_EnableMasterReceiverAutoSusp(hal_spi_handle_t *hspi);
HAL_SPI_DisableMasterReceiverAutoSusp(hal_spi_handle_t *hspi);

HAL_SPI_MASTER_EnableKeepIOState(hal_spi_handle_t *hspi);
HAL_SPI_MASTER_DisableKeepIOState(hal_spi_handle_t *hspi);

HAL_SPI_EnableIOSwap(hal_spi_handle_t *hspi);
HAL_SPI_DisableIOSwap(hal_spi_handle_t *hspi);

HAL_SPI_EnableReadyPin(hal_spi_handle_t *hspi);
HAL_SPI_DisableReadyPin(hal_spi_handle_t *hspi);

HAL_SPI_SetReadyPinPolarity(hal_spi_handle_t *hspi, hal_spi_ready_pin_polarity_t polarity);

Related concept: Replaced TypeDef suffix with _t in type names


HAL SPI handle type definition

HAL1

HAL2

SPI_HandleTypeDef;
hal_spi_handle_t;

Related concepts:


HAL SPI autonomous mode configuration type definition

In HAL2, the TriggerState is removed. Use HAL_SPI_EnableAutonomousModeTrigger() and HAL_SPI_DisableAutonomousModeTrigger() instead.

HAL1

HAL2

typedef struct
{
  uint32_t TriggerState;
  uint32_t TriggerSelection;
  uint32_t TriggerPolarity;
} SPI_AutonomousModeConfTypeDef;
typedef struct
{
  /* */
  hal_spi_am_trig_source_t     source;
  hal_spi_am_trig_polarity_t   polarity;
} hal_spi_am_trig_config_t;

HAL SPI callback type definition

HAL 1

HAL 2

pSPI_CallbackTypeDef

hal_spi_cb_t

Related concept: ref: breaking_concepts_concept_I2